<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="login.css">

</head>

<body>
<form action="login.php" method="post">
    <div class="title">
        <h3>登陆</h3> <a href="register.html" class="re-btn">注册</a>
    </div>

    <div class="list">
        <label for="fname">用户名：</label>
        <input type="text" name="fname" id="fname" pattern="[A-Za-z\-\u4e00-\u9fa5]{2,6}"
               placeholder="请输入用户名"  title="格式错误">
    </div>
    <div class="list">
        <label for="pwdL">密码：</label>
        <input type="password" name="pwdL" id="pwdL" pattern="[\d]{6,12}" placeholder="请输入密码"
               title="格式错误(至少六位数密码)">
    </div>
        <button class="login" type="submit" id="loginBtn">登陆</button>

</form>


<script src="login.js"></script>
<script>
    addLoadEvent(login);


function login() {
    var fname = getId("#fname"),
        pwdL = getId("#pwdL"),
        loginBtn = getId("#loginBtn");
    loginBtn.onclick = function () {
        if (fname.value === "") {
            alert("用户名不能为空");
            return false;
        } else if (pwdL.value === "") {
            alert("密码不能为空");
            return false;
        }
    };
}


</script>
</body>
</html>